package com.vogue.supplymall.order.domain.biz;

import com.vogue.supplymall.common.annotation.AkkaRemoteServer;
import com.vogue.supplymall.common.domain.dto.OrderDetailInfo;
import com.vogue.supplymall.common.domain.dto.OrderInfo;
import com.vogue.supplymall.common.domain.dto.UserInfo;
import com.vogue.supplymall.order.domain.model.Order;
import com.vogue.supplymall.order.domain.model.OrderStatus;
import com.vogue.supplymall.order.exception.UpdateOrderException;
import com.vogue.supplymall.payment.dto.CallbackInputParameter;
import com.vogue.supplymall.payment.dto.IResultParameter;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Map;

/**
 * The interface Order update biz.
 *
 * @aouthor: zhangliang
 * @date: Create in 2018-02-07
 */
@AkkaRemoteServer
public interface OrderUpdateBiz extends Serializable {

    /**
     * Update freight boolean.
     * 更新订单运费
     *
     * @param detailInfo the detail info
     * @param userInfo   the user info
     * @return the boolean
     */
    public Map<String, Object> updateFreight(OrderDetailInfo detailInfo, UserInfo userInfo);

    /**
     * Update status boolean.
     * 更新订单状态
     *
     * @param detailInfo the detail info
     * @param userInfo   the user info
     * @return the boolean
     */
    public Boolean updateStatus(OrderDetailInfo detailInfo, UserInfo userInfo);

    /**
     * Order receiving.
     * 收货生成退货单处理
     *
     * @param order    the order
     * @param status   the status
     * @param userInfo the user info
     */
    public void orderReceiving(Order order, OrderStatus status, UserInfo userInfo);

    /**
     * Order pay offline boolean.
     * 订单线下支付
     *
     * @param orderDetailInfo the order detail info
     * @return the boolean
     */
    public void orderPayOffline(OrderDetailInfo orderDetailInfo);

    /**
     * Order cancel.
     * 取消订单
     *
     * @param orderDetailInfo the order detail info
     */
    public void orderCancel(OrderDetailInfo orderDetailInfo);

    /**
     * Order delete.
     * 删除订单
     *
     * @param orderDetailInfo the order detail info
     */
    public void orderDelete(OrderDetailInfo orderDetailInfo);

    /**
     * Order agree cancel.
     * 卖家处理买家取消订单申请
     *
     * @param orderDetailInfo the order detail info
     */
    public void orderAgreeCancel(OrderDetailInfo orderDetailInfo);

    /**
     * 支付接口调用成功回调接口
     *
     * @param callbackInputParameter 回调接口的信息参数
     * @param callbackSecretKey      对接吾享支付接口支付成功回调密钥
     * @return
     * @throws Exception the exception
     */
    public Integer callBackFunction(CallbackInputParameter callbackInputParameter, String callbackSecretKey);

    /**
     * 撤销订单付款接口
     *
     * @param orderid 订单id
     * @throws UpdateOrderException the update order exception
     */
    public void orderPayCancel(Long orderid) throws UpdateOrderException;

    /**
     * 关闭订单交易接口
     *
     * @param orderid the orderid
     * @throws UpdateOrderException the update order exception
     */
    public void orderPayClose(Long orderid) throws UpdateOrderException;

    /**
     * 线上支付获取信息
     *
     * @param orderInfo the order info
     * @return result parameter
     */
    public IResultParameter payOnline(OrderInfo orderInfo);

    /**
     * 线上支付获取信息
     *
     * @param orderInfo 封装的订单信息
     * @param amount 支付金额（自己指定）
     * @return result 接口返回数据封装
     */
    public IResultParameter payOnline(OrderInfo orderInfo, BigDecimal amount) throws Exception;
    
    /**
     * 待支付的订单查询下是否已经支付过并且成功如果是则刷新状态变成已付款
     *
     * @param orderid the orderid
     * @return 返回订单最新状态 0:待付款 1:已付款
     * @throws Exception the exception
     */
    public Integer refreshOrderPayStatus(Long orderid) throws Exception;

    /**
     * 预付货款支付
     *
     * @param orderInfo 订单信息
     */
    public void payAdvance(OrderInfo orderInfo);

    /**
     * 预付货款支付(延时改状态)
     * @param orderInfo 订单信息
     */
    public void payAdvanceTs(OrderInfo orderInfo);
    
    /**
     * 预付货款支付
     * @param orderInfo 订单信息
     * @param amount 支付金额（自己指定）
     */
    public OrderStatus payAdvance(OrderInfo orderInfo, BigDecimal amount);
    
    /**
     * 组合方式付款
     * @param orderInfo       the order info
     * @param orderDetailInfo the order detail info
     * @return the result parameter
     */
    public IResultParameter payCombinationPayment(OrderInfo orderInfo, OrderDetailInfo orderDetailInfo);
    
    /**
     * 订单还原占用的商品库存
     * @param orderid 订单id
     */
    public void returnProductInventory(Long orderid);
    
    /**
     * 线下支付保存支付记录功能模块
     * @param orderid 订单id
     * @param amount 订单金额
     */
    public void payOfflinePayment(Long orderid, BigDecimal amount);
    
    /**
     * 删除订单的所有已存在的支付记录信息（在每次重新支付前）
     * @param orderid 订单id
     * @throws Exception 错误异常
     */
    public void deleteAllPayment(Long orderid) throws Exception;
    
    /**
     * 根据卖家店铺设置的是否手动接单标志来设置订单的状态
     * @param orderStatus 订单状态对象
     */
    public void saveOrderStateByShopWaitingOrder(OrderStatus orderStatus);
}
